<template>
    <div>
        <button @click="changeLanguage">{{ language }}</button>
        <h1>sub index page</h1>
        <input v-model="msg" type="text" @input.prevent="inputMsg">
    </div>
</template>

<script setup lang="ts">
import { ref, onMounted, computed } from 'vue'
import actions from '@/utils/qiankun-action';
import layoutStore from '@/store/index'
import {I18NType} from '@/app.config'

const store = layoutStore()
const msg = ref('')
const inputMsg = () => {
    actions.setGlobalState({
        msg: msg.value
    })
}

const language = computed(() => store.getLanguage)
const changeLanguage = () => {
    store.setLanguage(language.value == I18NType.EN_US ? I18NType.ZH_CN : I18NType.EN_US)
}

onMounted(() => {
    // actions.onGlobalStateChange((state: any) => {
    //     console.log('index onmouted', state)
    // }, true)
    console.log('store.getSubApp', store.getSubApp)
})
</script>

<style lang="less" scoped>

</style>